package jtk.project4.fleet.screen.addAttachment;

import java.sql.SQLException;

import jtk.project4.fleet.FleetModel;
import jtk.project4.fleet.domain.Attachments;
import jtk.project4.fleet.domain.PmHist;
import jtk.project4.fleet.event.AddAttachmentEvent;
import jtk.project4.fleet.event.AddMaintenanceTaskEvent;
import nl.coderight.jazz.Controller;

public class AddAttachmentController extends Controller{
	private FleetModel fleetModel;
	private AddAttachmentView addAttachmentView;

	public void handleEvent(AddAttachmentEvent evt) throws SQLException {
		Attachments attachments = fleetModel.getAttachment();
		switch (evt.getType()) {
		case SAVE:
			fleetModel.insertAttachments(attachments);
			break;
		default:
			propagateEvent(evt);
			break;
		}
	}
	
	@Override
	public void execute() {
		fleetModel = (FleetModel) getModel();
		addAttachmentView = new AddAttachmentView();
		setView(addAttachmentView);
		showView();
	}

}